﻿<div ng-controller="bazaarProductController">
    <div class="wrapper border-bottom white-bg page-heading">
        <div class="col-lg-pull-12">
            <ol class="breadcrumb">
                <li>商品管理</li>
            </ol>
        </div>
    </div>
    <form class="form-horizontal row">
        <div class="form-group">
            <div class="col-md-4">
                <label class="col-sm-4 control-label">商品名称</label>
                <div class="col-sm-7">
                    <input name="name" type="text" class="form-control input-sm" ng-model="query.product_name">
                </div>
            </div>
            <div class="col-sm-4">
                <label class="col-sm-4 control-label">时间</label>
                <div class="col-sm-8">
                    <div date class="input-group date">
                        <input class="form-control input-sm" ng-model="query.start_time">
                        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <label class="col-sm-1 control-label">至</label>
                <div class="col-sm-8">
                    <div date class="input-group date">
                        <input class="form-control input-sm" ng-model="query.end_time">
                        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                    </div>
                </div>
            </div>

        </div>
        <div class="form-group">
            <div class="col-md-4">
                <label class="col-sm-4 control-label">用户名称</label>
                <div class="col-sm-7">
                    <input name="name" type="text" class="form-control input-sm" ng-model="query.merchant_name">
                </div>
            </div>
            <div class="col-sm-4">
                <label class="col-sm-4 control-label">商品状态</label>
                <div class="col-sm-8">
                    <div class="col-sm-12">
                        <select name="status" class="form-control input-sm" ng-model="query.status">
                            <option value="">请选择</option>
                            <option value="0">待审核</option>
                            <option value="1">上架中</option>
                            <option value="2">已下架</option>
                            <option value="3">已删除</option>
                            <option value="4">已交易</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <label class="col-sm-4 control-label">推荐状态</label>
                <div class="col-sm-8">
                    <div class="col-sm-12">
                        <select name="is_recommend" class="form-control input-sm" ng-model="query.is_recommend">
                            <option value="">请选择</option>
                            <option value="1">已推荐</option>
                            <option value="0">未推荐</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <div class="col-sm-offset-4 col-sm-8">
                    <button class="btn btn-primary btn-sm" ng-click="search(query)"><i class="fa fa-search"></i> 查询</button>
                </div>
            </div>
        </div>
    </form>
    <table style="table-layout:fixed;" class="table table-hover m-t-md">
        <thead>
            <tr style="background-color: #f7f7f9;">
                <th>序号</th>
                <th>图片</th>
                <th>商品名称</th>
                <th>商品库存</th>
                <th>红钻</th>
                <th>市场价格</th>
                <th width="100">所属用户|账号</th>
                <th>商品分类</th>
                <th>状态</th>
                <th>是否已推荐</th>
                <th>更新时间</th>
                <th width="65">操作</th>
            </tr>
        </thead>
        <tbody ng-repeat="item in model.rows">
            <tr>
                <td>{{$index+1}}</td>
                <td><img width="50" height="50" src="{{site.img_url+item.main_img}}" /></td>
                <td>
                    {{item.product_name}}
                </td>
                <td>{{item.num}}</td>
                <td>{{item.price}}</td>
                <td>{{item.market_price}}</td>
                <td>
                    {{item.merchant_name}}<br />{{item.merchant_mobile}}
                </td>
                <td>
                    {{item.catagory_name}}
                </td>
                <td ng-if="item.status==0" style="color:red">
                    {{item.status_desc}}
                </td>
                <td ng-if="item.status==1" style="color:blue">
                    {{item.status_desc}}
                </td>
                <td ng-if="item.status==2" style="color:black">
                    {{item.status_desc}}
                </td>
                <td ng-if="item.status==3" style="color:gray">
                    {{item.status_desc}}
                </td>
                <td ng-if="item.status==4" style="color:brown">
                    {{item.status_desc}}
                </td>
                <td style="{{item.is_recommend?"color:'red':''"}}">
                    {{item.is_recommend?"已推荐":"未推荐"}}
                </td>
                <td>{{item.update_time}}</td>
                <td>
                    <a class="btn btn-primary btn-xs" ui-sref="app.bazaarProduct.detail({id:{{item.id}}})"><i class="fa fa-cog"></i> 详情</a>
                    <a ng-if="item.status==0" class="btn btn-primary btn-xs" ui-sref="app.bazaarProduct.audit({id:{{item.id}}})"><i class="fa fa-cog"></i> 审核</a>
                    <a ng-if="item.status==1" class="btn btn-primary btn-xs" ng-click="down(item.id)"><i class="fa fa-cog"></i> 下架</a>
                    <a ng-if="item.is_recommend" class="btn btn-primary btn-xs" ng-click="recommend(item.id, 0)"><i class="fa fa-cog"></i> 取消推荐</a>
                    <a ng-if="!item.is_recommend " class="btn btn-primary btn-xs" ng-click="recommend(item.id, 1)"><i class="fa fa-cog"></i> 推荐</a>
                </td>
            </tr>
        </tbody>
    </table>
    <div class="row">
        <div class="col-md-12">
            <uib-pagination total-items="model.total_result" items-per-page="model.size" ng-model="model.page" num-pages="model.total_pages"
                            ng-change="search_page(model.page)" class="pagination-sm" boundary-links="true" boundary-link-numbers="true" max-size="20"
                            previous-text="&lsaquo;" next-text="&rsaquo;" first-text="&laquo;" last-text="&raquo;"></uib-pagination>
            <span class="pull-right" style="margin: 30px 0px 20px 0px">共{{model.total_result}} 当前：{{model.page}}/{{model.total_pages}}</span>
        </div>
    </div>
</div>
